import service from './request'

let commonHeader = () => ({ 'Content-Type': 'multipart/form-data' });
// 文件上传
/**
 *
 * @param {string} url
 * @param {FormData} formData
 * @param {*} params URL参数
 */
export const fileUpload = async (url,{
    formData,params={}}) => {
    return service.post(url + parseParams(params),formData,{
        headers: commonHeader()
    })
};
/**
 *
 * @param {*} params
 */
export const parseParams = (params = {}) => {
    console.log(params);
    let url = '?';
    for (let key in params) {
        url += `${key}=${params[key]}`;
        url += '&'
    }
    return url.substr(0, url.length - 1)
}